import java.awt.Color;


/*
 * Player-class, desribes the Player.
 */
public class Player {
	private int startX;
	private int startY;
	private int x;
	private int y;
	private int radius;
	private Color c;
	private int xSpeed = 0;
	private int ySpeed = 0;
	private Boolean flag;
	private int score;
	private Boolean xSi;
	private Boolean xSd;
	private Boolean ySi;
	private Boolean ySd;
	/*
	 *Constructor: [int x, int y, int radius, Color c] 
	 * 
	 */
	public Player(int x1, int y1, int r1, Color c1) {
		startX = x1;
		startY = y1;
		x = x1;
		y = y1;
		radius = r1;
		c = c1;
		flag = false;
		score = 0;
		xSi = false;
		xSd = false;
		ySi = false;
		ySd = false;
	}
	
	public void setXi(Boolean b) {
		xSi = b;
	}
	
	public void setXd(Boolean b) {
		xSd = b;
	}
	
	public void setYi(Boolean b) {
		ySi = b;
	}
	
	public void setYd(Boolean b) {
		ySd = b;
	}
	
	public Boolean xI() {
		return xSi;
	}
	
	public Boolean xD() { 
		return xSd;
	}
	
	public Boolean yI() {
		return ySi;
	}
	
	public Boolean yD() {
		return ySd;
	}
	
	public int getScore() {
		return score;
	}
	
	public void setScore(int i) {
		score = i;
	}
	
	public void incScore() {
		score++;
	}
	
	public int getRadius() {
		return radius;
	}
	
	public Color getColor() {
		return c;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public int getXSpeed() {
		return xSpeed;
	}
	
	public int getYSpeed() {
		return ySpeed;
	}
	/*
	 * Methods to increase the Players speed.
	 */
	public synchronized void  xSpeedInc() {
		if (xSpeed < 9) {
			xSpeed++;
		}
	}
	
	public synchronized void xSpeedDec() {
		if (xSpeed > -9) {
			xSpeed--;
		}
	}
	
	public synchronized void ySpeedInc() {
		if (ySpeed < 9) {
			ySpeed++;
		}
	}
	
	public synchronized void ySpeedDec() {
		if (ySpeed > -9) {
			ySpeed--;
		}
	}
	
	public synchronized void updatePlayer() {
		if (x > 0 && x < 1000 - radius && y > 0 && y < 500 - radius) {
			x = x + xSpeed;
			y = y + ySpeed;
		}
		else {
			resetPlayer();
		}
	}
	
	public Boolean hasFlag() {
		return flag;
	}
	
	public void catchFlag(Boolean b) {
		flag = b;
	}
	
	public void resetPlayer() {
		
		x = startX;
		y = startY;
		xSpeed = 0;
		ySpeed = 0;
		flag = false;
	}
}
